package ride

// Distance 距离
type Distance struct {
	Total int
}

// AmountOfBasic 基础里程
func (d Distance) AmountOfBasic() int {
	return 2
}

// AmountOfExtra 超出的里程
func (d Distance) AmountOfExtra() int {
	if d.Total > 2 {
		return d.Total - 2
	}
	return 0
}

// AmountOfLong 长途里程
func (d Distance) AmountOfLong() int {
	if d.Total > 8 {
		return d.Total - 8
	}
	return 0
}

// Price 里程对应的价格
func (d Distance) Price() float64 {
	return float64(d.AmountOfBasic()*3) + float64(d.AmountOfExtra())*0.8 + float64(d.AmountOfLong())*0.4
}
